/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.component.gateway.dianlan.bits;

import info.peigen.hotpot.component.gateway.dianlan.bits.base.BitParserBase;
import info.peigen.hotpot.component.gateway.dianlan.protocol.passive.DianlanDcStubForwardDataGram;

/**
 * <b>(DianlanDcStubForwardDataGramReasonBits)</b>
 * <p>
 * BMS转发充直流充电时电机报文-解析
 *
 * @author LiDaHai
 * @version 1.0.0
 * @since 2023/1/12
 */
public class DianlanDcStubForwardDataGramReasonBits extends BitParserBase {

    public DianlanDcStubForwardDataGram parseReason(String hexString) {
        String[]                     hexStrArray = hexStrToArray(hexString);
        DianlanDcStubForwardDataGram info        = DianlanDcStubForwardDataGram.builder().build();
        info.setTotalChargeTime(parseInt(hexStrArray[1] + hexStrArray[0]) + "");
        info.setTotalChargeEnergy(0.1d * parseInt(hexStrArray[3] + hexStrArray[2]));
        info.setStubNo(parseInt(hexStrArray[4]) + "");
        info.setChargeEnergy(0.1d * parseInt(hexStrArray[6] + hexStrArray[5]));
        info.setReserve(hexStrArray[7] + "");
        return info;
    }
}